class Solution19 {
    int ret;
    public int findTargetSumWays(int[] nums, int target) {
        dfs(nums,0,target,0);
        return ret;
    }

    public void dfs(int[] nums,int pos,int target,int path) {
        if(pos == nums.length) {
            if(path == target) ret++;
            return;
        }

        //加
        dfs(nums,pos+1,target,path + nums[pos]);
        //减
        dfs(nums,pos+1,target,path - nums[pos]);
    }
}